/**
 * @param {number[]} nums
 * @return {number}
 */
 var triangularSum = function(nums) {
  let arr = [...nums]
  let ans = arr[0]
  for(let i = 0; i<nums.length-1; i++) {
    let sum = 0, next = []
    for(let i = 0; i<arr.length-1; i++) {
      next.push((arr[i] + arr[i+1]) % 10)
    }
    ans = next[0]
    arr = next
  }
  return ans % 10
};